package cn.gson.crm.model.dao;

import java.sql.SQLException;
import java.util.Map;

import cn.gson.crm.model.Jdbc;
import cn.gson.crm.model.entity.Interview;

public class InterviewDao {
	/**
	 * 保存面试信息
	 * @param attachs
	 * @return
	 * @throws SQLException
	 */
	public Long saveInterview(Interview view) throws SQLException {
		String insertSql = "insert into `interview` (stu_id,company_name,company_address,interview_time,interview_summary) values (?,?,?,?,?);";
		// 如果记录插入成功，获取最新记录ID
		if (Jdbc.getInstace().executeUpdate(insertSql, view.getStuId(),view.getCompanyName(),view.getCompanyAddress(),view.getInterviewTime(),view.getInterviewSummary())) {
			String sql = "select view_id from interview order by view_id desc limit 1";
			Map<String, Object> map = Jdbc.getInstace().executeQuery(sql);
			if (map != null) {
				return Long.parseLong(map.get("view_id").toString());
			}
		}
		return null;
	}
}
